package com.cqhgcloud.monarch.organ.controller;

import java.util.Arrays;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cqhgcloud.monarch.organ.entity.RoleMeun;
import com.cqhgcloud.monarch.organ.service.RoleMeunService;
import com.cqhgcloud.monarch.organ.util.R;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;

/**
 * @param 角色菜单表
 * @author weimeilayer@gmail.com
 * @date 2020-01-31 22:33:01
 */
@RestController
@AllArgsConstructor
@Api(value = "角色菜单表操作接口")
@RequestMapping("/rolemeun")
public class RoleMeunController {
	
	private RoleMeunService roleMeunService;

	/**
	 * 列表
	 */
	@ApiOperation(value = "分页查询", notes = "分页查询roleMeun 角色菜单表")
	@GetMapping("/pagelist")
	public R list(Page page, RoleMeun roleMeun) {
		return R.ok(roleMeunService.queryPage(page, roleMeun));
	}

	/**
	 * 信息
	 */
	@ApiOperation(value = "通过id查询", notes = "通过id查询roleMeun 角色菜单表")
	@GetMapping("/info/{roleMenuId}")
	public R info(@PathVariable("roleMenuId") String roleMenuId) {
		return R.ok(roleMeunService.getById(roleMenuId));
	}

	/**
	 * 保存
	 */
	@ApiOperation(value = "保存", notes = "保存角色菜单表")
	@PostMapping("/save")
	public R save(@RequestBody RoleMeun roleMeun) {
		return R.ok(roleMeunService.save(roleMeun));
	}

	/**
	 * 修改角色菜单表
	 * 
	 * @param roleMeun 角色菜单表
	 * @return R
	 */
	@ApiOperation(value = "修改角色菜单表", notes = "修改角色菜单表")
	@PutMapping("/update")
	public R update(@RequestBody RoleMeun roleMeun) {
		return R.ok(roleMeunService.updateById(roleMeun));
	}

	/**
	 * 删除
	 */
	@ApiOperation(value = "通过id删除角色菜单表", notes = "通过id删除角色菜单表")
	@DeleteMapping("/delete")
	public R delete(@RequestBody String[] roleMenuIds) {
		return R.ok(roleMeunService.removeByIds(Arrays.asList(roleMenuIds)));
	}
}